package HibernateOrederManagement.app;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import HibernateOrderManagerment.bean.User;

public class LoginDao {
	private Session  session;
	public LoginDao(Session session){
		this.session=session;
	}
	
	public User login(String username,String password){
		
		Criteria criteria =session.createCriteria(User.class);
		criteria.add(Restrictions.eq("username", username));
		criteria.add(Restrictions.eq("password", password));
		List<?> list=criteria.list();
		User user=null;
		if(list.size()>0){
			 user=(User) list.get(0);
		}
		return user;
	}

}
